import java.util.Scanner;

public class C_1084 {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt();
		int n = sc.nextInt();
		int t = n/m;
		int yu = n%m;
		long num = 0;
		int start = (int) (Math.pow(2, m)-2);
		int temp = 0;
		for(int i = 1;i<=start;i++) {
			temp+=i;
		}
		num = temp;
		for(int i = 0;i<t-2;i++) {
			if(start==0)
				break;
			temp = temp - start;
			num+=temp;
			start--;
		}
		System.out.println(num);
	}

}
